const app = getApp()
Page({
    data: {
        url: ''
    },
    onLoad(options) {
        wx.showLoading({
            title: '页面加载中...',
        })
        var ticket = options.ticket;
        let This = this
        wx.login({
            success(res) {
                if (res.code) {
                    let wxTime = new Date().getTime()
                    var url = app.globalData.urleducation + ticket;
                    if (url.indexOf('?') != -1) {
                        url = `${url}&code=${res.code}&wechatType=${app.globalData.wechatType}`
                    } else {
                        url = `${url}?code=${res.code}&wechatType=${app.globalData.wechatType}`
                    }
                    url = `${url}?wxTime=${wxTime}`
                    This.setData({
                        url: url
                    })
                    debugger;
                    setTimeout(() => {
                        wx.hideLoading()
                    }, 2000)
                } else {
                    console.log('登录失败！' + res.errMsg)
                }
            }
        })

        // app.callback = url => {
        //     this.setData({
        //         url: url
        //     })
        // }
    },
    h5PostMessage: function(e) {
        console.log(e.detail.data)
        this.h5Data = e.detail.data[e.detail.data.length - 1]; //当用户点击这个h5页面的分享时获取到
    },

    // 用户点击右上角分享
    onShareAppMessage: function(options) {
        return {
            title: this.h5Data.title,
            desc: this.h5Data.desc,
            path: this.h5Data.path
        }
    },
    h5Load: function() {
        // wx.hideLoading()
    },
    h5LoadError: function(e) {
        // wx.hideLoading()
        wx.showToast({
            title: e.detail,
            duration: 2000
        })
    }
})